<template>
	<view class="login-page">
		<view class="login-page-title">绑定手机号</view>
		<view class="input-bar">
			<input class="input" v-model="phoneNum" placeholder="请输入手机号"></input>
		</view>
		<largeBtn :disabled="btnDisabled" @btnClk="toNext">下一步</largeBtn>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				phoneNum: ''
			}
		},
		computed: {
			btnDisabled() {
				// const flag = /^1\d{10}/.test(this.phoneNum)
				const flag = true
				return !flag
			}
		},
		methods: {
			toNext() {
				this.checkPhoneIsreged()
			},
			// 校验手机号是否注册过
			checkPhoneIsreged(){
				this.$api.checkPhoneIsreged(this.phoneNum).then((res)=>{
					if(!res){
						// 未注册,去注册
						uni.navigateTo({
							url: `/pages/login/passwordAndVcode?phone=${this.phoneNum}&pageType=3`
						})
					}else{
						// 已注册,去输入个验证码
						uni.navigateTo({
							url: `/pages/login/validateCode?phone=${this.phoneNum}&pageType=2`
						})
					}
				})
			},
		}
	}
</script>

<style lang="less" scoped>
	.login-page {
		width: 670rpx;
		margin: 0 auto;
		padding-top: 54rpx;

		.login-page-title {
			font-size: 48rpx;
			font-weight: 400;
			color: #323746;
			line-height: 60rpx;
		}

		.login-page-tips {
			margin-top: 16rpx;
			font-size: 24rpx;
			font-weight: 400;
			color: #9196A0;
			line-height: 32rpx;
		}

		.input-bar {
			margin-top: 60rpx;
			margin-bottom: 120rpx;
			height: 120rpx;
			border-bottom: 2rpx solid #DDDDDD;
			display: flex;
			align-items: center;

			.input {
				width: 100%;
				font-size: 36rpx;
				font-weight: 400;
				color: #9196A0;
				line-height: 44rpx;
			}

		}

		.other-way {
			margin: 0 auto;
			margin-top: 76rpx;
			width: 550rpx;
			border-top: 1rpx solid #DDDDDD;
			position: relative;
			padding-top: 74rpx;
			display: flex;
			justify-content: center;

			.other-way-tips {
				font-size: 24rpx;
				font-weight: 400;
				color: #9196A0;
				line-height: 32rpx;
				padding: 0 20rpx;
				background-color: #fff;
				position: absolute;
				left: 50%;
				top: 0;
				transform: translate(-50%, -50%);
			}

			.other-way-item {
				display: flex;
				align-items: center;
				flex-direction: column;

				.way-icon {
					width: 96rpx;
					height: 96rpx;
				}

				.way-name {
					margin-top: 10rpx;
					font-size: 24rpx;
					font-weight: 400;
					color: #4A505C;
					line-height: 32rpx;

				}
			}
		}
	}
</style>
